package com.hellobike.haxing.modules.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hellobike.haxing.modules.product.entity.PromotionGroupSku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * @Description: 拼团SKU
 * @Author: haxing-boot
 * @Date: 2020-01-30
 * @Version: V1.0
 */
public interface PromotionGroupSkuMapper extends BaseMapper<PromotionGroupSku> {

    @Update("update t_promotion_group_sku set stock_left = stock_left + #{left} where  id = #{id}")
    void incrementStockLeft(@Param("id") Long id, @Param("left") Integer left);

    @Update("UPDATE t_promotion_group_sku SET stock_left = stock_left + #{changeNum} WHERE id = #{groupSkuId} AND stock_left >= 0 - #{changeNum} AND deleted = 0")
    int changeGroupSkuStock(@Param("groupSkuId") Long groupSkuId, @Param("changeNum") Integer changeNum);

}

